#pragma once
#include "tetromino.h"

namespace gm
{
    class Piece
    {
    public:
        Piece() = default;
        Piece(Tetromino& t, int x0, int y0, int i);
        ~Piece() = default;
        void down(int dy = 1);
        void left();
        void right();
        void rotate();
        void set_playField(Matrix* p);
        void change_tetro(Tetromino& t);
        std::pair<int, int> get_mino(int i) const;
        std::pair<int, int> get_xy() const;
        int get_color() const;
        int get_gy() const;
        Tetromino get_tetro() const;
        bool test(int x, int y);

        static Matrix* p_playField;
    private:
        void move(int dx = 0, int dy = 0);
        void changed_gy();
    private:
        Tetromino tetro_set;
        const Tetromino* SRS = nullptr;
        int index;  // [0 R 2 L]
        int x, y;   // 正交直角坐标系
        int gy;     // 阴影y
    };
} // namespace gm